import { http } from '@/utils/request'
import type { QueryParams, ExportResponse, LoginInfor } from './type'

const prefix = import.meta.env.VITE_API_SYS

// 查询登录日志列表
export function list(query: QueryParams & Page) {
	return http.get<ResPage<LoginInfor[]>>(`${prefix}/logininfor/list`, query)
}

// 删除登录日志
export function delLogininfor(infoId: string): Promise<any> {
	return http.delete(`${prefix}/logininfor/${infoId}`)
}

// 解锁用户登录状态
export function unlockLogininfor(userName: string) {
	return http.get(`${prefix}/logininfor/unlock/${userName}`)
}

// 清空登录日志
export function cleanLogininfor() {
	return http.delete(`${prefix}/logininfor/clean`)
}

// 导出
export function operLogininfor(params: QueryParams & Page) {
	return http.postFile<ExportResponse>(`${prefix}/logininfor/export`, params, {
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		responseType: 'blob'
	})
}
